﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using TryJSONLoginSystem.LoginDataSetTableAdapters;
using System.Data;

namespace TryJSONLoginSystem
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Login" in code, svc and config file together.
    public class Login : ILogin
    {
        LoginTableTableAdapter adapter = new LoginTableTableAdapter();

      


        string ILogin.newlogin(string loginName, string password)
        {
            adapter.Insert(loginName, password);
            return "sucess";
        }

        public string loginSuccess(string loginName, string password)
        {
           for (int i = 0; i < adapter.GetDataBy(loginName).Count; i++)
            {
                string login = adapter.GetDataBy(loginName)[i].loginName;
                if (adapter.GetDataBy(loginName)[i].password == password) {
                    return "sucess";
                } 
            }
            return "failed";
        }

       
    }
}
